/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vfaq.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.vfaq.model.FAQAnswer;
import com.vportal.portlet.vfaq.model.FAQAnswerModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the FAQAnswer service. Represents a row in the &quot;FAQAnswer&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vfaq.model.FAQAnswerModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link FAQAnswerImpl}.
 * </p>
 *
 * @author DucNN
 * @see FAQAnswerImpl
 * @see com.vportal.portlet.vfaq.model.FAQAnswer
 * @see com.vportal.portlet.vfaq.model.FAQAnswerModel
 * @generated
 */
public class FAQAnswerModelImpl extends BaseModelImpl<FAQAnswer>
	implements FAQAnswerModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a f a q answer model instance should use the {@link com.vportal.portlet.vfaq.model.FAQAnswer} interface instead.
	 */
	public static final String TABLE_NAME = "FAQAnswer";
	public static final Object[][] TABLE_COLUMNS = {
			{ "uuid_", Types.VARCHAR },
			{ "id_", Types.BIGINT },
			{ "questionid", Types.BIGINT },
			{ "content", Types.VARCHAR },
			{ "answerOrder", Types.BIGINT },
			{ "answeredByUser", Types.VARCHAR },
			{ "answeredDate", Types.TIMESTAMP },
			{ "modifiedByUser", Types.VARCHAR },
			{ "language", Types.VARCHAR },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "approved", Types.BOOLEAN },
			{ "approvedByUser", Types.VARCHAR },
			{ "approvedDate", Types.TIMESTAMP },
			{ "userId", Types.BIGINT },
			{ "attachName", Types.VARCHAR },
			{ "folderId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table FAQAnswer (uuid_ VARCHAR(75) null,id_ LONG not null primary key,questionid LONG,content VARCHAR(2000) null,answerOrder LONG,answeredByUser VARCHAR(300) null,answeredDate DATE null,modifiedByUser VARCHAR(300) null,language VARCHAR(150) null,modifiedDate DATE null,approved BOOLEAN,approvedByUser VARCHAR(300) null,approvedDate DATE null,userId LONG,attachName VARCHAR(500) null,folderId LONG)";
	public static final String TABLE_SQL_DROP = "drop table FAQAnswer";
	public static final String ORDER_BY_JPQL = " ORDER BY faqAnswer.answeredDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY FAQAnswer.answeredDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vfaq.model.FAQAnswer"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vfaq.model.FAQAnswer"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vfaq.model.FAQAnswer"),
			true);
	public static long APPROVED_COLUMN_BITMASK = 1L;
	public static long LANGUAGE_COLUMN_BITMASK = 2L;
	public static long QUESTIONID_COLUMN_BITMASK = 4L;
	public static long UUID_COLUMN_BITMASK = 8L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vfaq.model.FAQAnswer"));

	public FAQAnswerModelImpl() {
	}

	public long getPrimaryKey() {
		return _id;
	}

	public void setPrimaryKey(long primaryKey) {
		setId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_id);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return FAQAnswer.class;
	}

	public String getModelClassName() {
		return FAQAnswer.class.getName();
	}

	public String getUuid() {
		if (_uuid == null) {
			return StringPool.BLANK;
		}
		else {
			return _uuid;
		}
	}

	public void setUuid(String uuid) {
		if (_originalUuid == null) {
			_originalUuid = _uuid;
		}

		_uuid = uuid;
	}

	public String getOriginalUuid() {
		return GetterUtil.getString(_originalUuid);
	}

	public long getId() {
		return _id;
	}

	public void setId(long id) {
		_id = id;
	}

	public long getQuestionid() {
		return _questionid;
	}

	public void setQuestionid(long questionid) {
		_columnBitmask |= QUESTIONID_COLUMN_BITMASK;

		if (!_setOriginalQuestionid) {
			_setOriginalQuestionid = true;

			_originalQuestionid = _questionid;
		}

		_questionid = questionid;
	}

	public long getOriginalQuestionid() {
		return _originalQuestionid;
	}

	public String getContent() {
		if (_content == null) {
			return StringPool.BLANK;
		}
		else {
			return _content;
		}
	}

	public void setContent(String content) {
		_content = content;
	}

	public long getAnswerOrder() {
		return _answerOrder;
	}

	public void setAnswerOrder(long answerOrder) {
		_answerOrder = answerOrder;
	}

	public String getAnsweredByUser() {
		if (_answeredByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _answeredByUser;
		}
	}

	public void setAnsweredByUser(String answeredByUser) {
		_answeredByUser = answeredByUser;
	}

	public Date getAnsweredDate() {
		return _answeredDate;
	}

	public void setAnsweredDate(Date answeredDate) {
		_columnBitmask = -1L;

		_answeredDate = answeredDate;
	}

	public String getModifiedByUser() {
		if (_modifiedByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _modifiedByUser;
		}
	}

	public void setModifiedByUser(String modifiedByUser) {
		_modifiedByUser = modifiedByUser;
	}

	public String getLanguage() {
		if (_language == null) {
			return StringPool.BLANK;
		}
		else {
			return _language;
		}
	}

	public void setLanguage(String language) {
		_columnBitmask |= LANGUAGE_COLUMN_BITMASK;

		if (_originalLanguage == null) {
			_originalLanguage = _language;
		}

		_language = language;
	}

	public String getOriginalLanguage() {
		return GetterUtil.getString(_originalLanguage);
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public boolean getApproved() {
		return _approved;
	}

	public boolean isApproved() {
		return _approved;
	}

	public void setApproved(boolean approved) {
		_columnBitmask |= APPROVED_COLUMN_BITMASK;

		if (!_setOriginalApproved) {
			_setOriginalApproved = true;

			_originalApproved = _approved;
		}

		_approved = approved;
	}

	public boolean getOriginalApproved() {
		return _originalApproved;
	}

	public String getApprovedByUser() {
		if (_approvedByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _approvedByUser;
		}
	}

	public void setApprovedByUser(String approvedByUser) {
		_approvedByUser = approvedByUser;
	}

	public Date getApprovedDate() {
		return _approvedDate;
	}

	public void setApprovedDate(Date approvedDate) {
		_approvedDate = approvedDate;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public String getAttachName() {
		if (_attachName == null) {
			return StringPool.BLANK;
		}
		else {
			return _attachName;
		}
	}

	public void setAttachName(String attachName) {
		_attachName = attachName;
	}

	public long getFolderId() {
		return _folderId;
	}

	public void setFolderId(long folderId) {
		_folderId = folderId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public FAQAnswer toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (FAQAnswer)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					FAQAnswer.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		FAQAnswerImpl faqAnswerImpl = new FAQAnswerImpl();

		faqAnswerImpl.setUuid(getUuid());
		faqAnswerImpl.setId(getId());
		faqAnswerImpl.setQuestionid(getQuestionid());
		faqAnswerImpl.setContent(getContent());
		faqAnswerImpl.setAnswerOrder(getAnswerOrder());
		faqAnswerImpl.setAnsweredByUser(getAnsweredByUser());
		faqAnswerImpl.setAnsweredDate(getAnsweredDate());
		faqAnswerImpl.setModifiedByUser(getModifiedByUser());
		faqAnswerImpl.setLanguage(getLanguage());
		faqAnswerImpl.setModifiedDate(getModifiedDate());
		faqAnswerImpl.setApproved(getApproved());
		faqAnswerImpl.setApprovedByUser(getApprovedByUser());
		faqAnswerImpl.setApprovedDate(getApprovedDate());
		faqAnswerImpl.setUserId(getUserId());
		faqAnswerImpl.setAttachName(getAttachName());
		faqAnswerImpl.setFolderId(getFolderId());

		faqAnswerImpl.resetOriginalValues();

		return faqAnswerImpl;
	}

	public int compareTo(FAQAnswer faqAnswer) {
		int value = 0;

		value = DateUtil.compareTo(getAnsweredDate(),
				faqAnswer.getAnsweredDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		FAQAnswer faqAnswer = null;

		try {
			faqAnswer = (FAQAnswer)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = faqAnswer.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		FAQAnswerModelImpl faqAnswerModelImpl = this;

		faqAnswerModelImpl._originalUuid = faqAnswerModelImpl._uuid;

		faqAnswerModelImpl._originalQuestionid = faqAnswerModelImpl._questionid;

		faqAnswerModelImpl._setOriginalQuestionid = false;

		faqAnswerModelImpl._originalLanguage = faqAnswerModelImpl._language;

		faqAnswerModelImpl._originalApproved = faqAnswerModelImpl._approved;

		faqAnswerModelImpl._setOriginalApproved = false;

		faqAnswerModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<FAQAnswer> toCacheModel() {
		FAQAnswerCacheModel faqAnswerCacheModel = new FAQAnswerCacheModel();

		faqAnswerCacheModel.uuid = getUuid();

		String uuid = faqAnswerCacheModel.uuid;

		if ((uuid != null) && (uuid.length() == 0)) {
			faqAnswerCacheModel.uuid = null;
		}

		faqAnswerCacheModel.id = getId();

		faqAnswerCacheModel.questionid = getQuestionid();

		faqAnswerCacheModel.content = getContent();

		String content = faqAnswerCacheModel.content;

		if ((content != null) && (content.length() == 0)) {
			faqAnswerCacheModel.content = null;
		}

		faqAnswerCacheModel.answerOrder = getAnswerOrder();

		faqAnswerCacheModel.answeredByUser = getAnsweredByUser();

		String answeredByUser = faqAnswerCacheModel.answeredByUser;

		if ((answeredByUser != null) && (answeredByUser.length() == 0)) {
			faqAnswerCacheModel.answeredByUser = null;
		}

		Date answeredDate = getAnsweredDate();

		if (answeredDate != null) {
			faqAnswerCacheModel.answeredDate = answeredDate.getTime();
		}
		else {
			faqAnswerCacheModel.answeredDate = Long.MIN_VALUE;
		}

		faqAnswerCacheModel.modifiedByUser = getModifiedByUser();

		String modifiedByUser = faqAnswerCacheModel.modifiedByUser;

		if ((modifiedByUser != null) && (modifiedByUser.length() == 0)) {
			faqAnswerCacheModel.modifiedByUser = null;
		}

		faqAnswerCacheModel.language = getLanguage();

		String language = faqAnswerCacheModel.language;

		if ((language != null) && (language.length() == 0)) {
			faqAnswerCacheModel.language = null;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			faqAnswerCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			faqAnswerCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		faqAnswerCacheModel.approved = getApproved();

		faqAnswerCacheModel.approvedByUser = getApprovedByUser();

		String approvedByUser = faqAnswerCacheModel.approvedByUser;

		if ((approvedByUser != null) && (approvedByUser.length() == 0)) {
			faqAnswerCacheModel.approvedByUser = null;
		}

		Date approvedDate = getApprovedDate();

		if (approvedDate != null) {
			faqAnswerCacheModel.approvedDate = approvedDate.getTime();
		}
		else {
			faqAnswerCacheModel.approvedDate = Long.MIN_VALUE;
		}

		faqAnswerCacheModel.userId = getUserId();

		faqAnswerCacheModel.attachName = getAttachName();

		String attachName = faqAnswerCacheModel.attachName;

		if ((attachName != null) && (attachName.length() == 0)) {
			faqAnswerCacheModel.attachName = null;
		}

		faqAnswerCacheModel.folderId = getFolderId();

		return faqAnswerCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(33);

		sb.append("{uuid=");
		sb.append(getUuid());
		sb.append(", id=");
		sb.append(getId());
		sb.append(", questionid=");
		sb.append(getQuestionid());
		sb.append(", content=");
		sb.append(getContent());
		sb.append(", answerOrder=");
		sb.append(getAnswerOrder());
		sb.append(", answeredByUser=");
		sb.append(getAnsweredByUser());
		sb.append(", answeredDate=");
		sb.append(getAnsweredDate());
		sb.append(", modifiedByUser=");
		sb.append(getModifiedByUser());
		sb.append(", language=");
		sb.append(getLanguage());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", approved=");
		sb.append(getApproved());
		sb.append(", approvedByUser=");
		sb.append(getApprovedByUser());
		sb.append(", approvedDate=");
		sb.append(getApprovedDate());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", attachName=");
		sb.append(getAttachName());
		sb.append(", folderId=");
		sb.append(getFolderId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(52);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vfaq.model.FAQAnswer");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>uuid</column-name><column-value><![CDATA[");
		sb.append(getUuid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>id</column-name><column-value><![CDATA[");
		sb.append(getId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>questionid</column-name><column-value><![CDATA[");
		sb.append(getQuestionid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>content</column-name><column-value><![CDATA[");
		sb.append(getContent());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>answerOrder</column-name><column-value><![CDATA[");
		sb.append(getAnswerOrder());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>answeredByUser</column-name><column-value><![CDATA[");
		sb.append(getAnsweredByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>answeredDate</column-name><column-value><![CDATA[");
		sb.append(getAnsweredDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedByUser</column-name><column-value><![CDATA[");
		sb.append(getModifiedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>language</column-name><column-value><![CDATA[");
		sb.append(getLanguage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>approved</column-name><column-value><![CDATA[");
		sb.append(getApproved());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>approvedByUser</column-name><column-value><![CDATA[");
		sb.append(getApprovedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>approvedDate</column-name><column-value><![CDATA[");
		sb.append(getApprovedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>attachName</column-name><column-value><![CDATA[");
		sb.append(getAttachName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>folderId</column-name><column-value><![CDATA[");
		sb.append(getFolderId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = FAQAnswer.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			FAQAnswer.class
		};
	private String _uuid;
	private String _originalUuid;
	private long _id;
	private long _questionid;
	private long _originalQuestionid;
	private boolean _setOriginalQuestionid;
	private String _content;
	private long _answerOrder;
	private String _answeredByUser;
	private Date _answeredDate;
	private String _modifiedByUser;
	private String _language;
	private String _originalLanguage;
	private Date _modifiedDate;
	private boolean _approved;
	private boolean _originalApproved;
	private boolean _setOriginalApproved;
	private String _approvedByUser;
	private Date _approvedDate;
	private long _userId;
	private String _userUuid;
	private String _attachName;
	private long _folderId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private FAQAnswer _escapedModelProxy;
}